
import javax.swing.*;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class FlowChart extends JFrame{
	
	private DrawingArea area;
	private Container container;
	
	public FlowChart(){
		
		super("Flow Chart");
		container = getContentPane();
		
		JMenuBar menuBar = new JMenuBar();
		JMenuItem save = new JMenuItem("Save");
		JMenuItem open = new JMenuItem("Open");
		JMenu file = new JMenu("File");
		file.add(save);
		file.add(open);
		menuBar.add(file);
		setJMenuBar(menuBar);
		
		JToolBar toolBar = new JToolBar();
		container.add(toolBar, BorderLayout.EAST);
		BoxLayout box = new BoxLayout(toolBar, BoxLayout.Y_AXIS);
		toolBar.setLayout(box);
		
		JButton diamond = new JButton(new ImageIcon("Image/diamond.png"));
		toolBar.add(diamond);
		
		
		JButton start = new JButton("Start");
		toolBar.add(start);
		
		JButton stop = new JButton("Stop");
		toolBar.add(stop);
	
		JButton rombez = new JButton("Input/Output");
		toolBar.add(rombez);
		
		area = new DrawingArea();
		diamond.addActionListener(new SymbolChange("Diamond", area));
		
		
		Box box2 = Box.createHorizontalBox();
		
		JTextArea textArea = new JTextArea(10,15);
		box2.add(new JScrollPane(textArea));
		container.add(box2);
	
		box2.add(new JScrollPane(area));
		
		setSize(1000,1000);
		setVisible(true);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	private class SymbolChange implements ActionListener{

		private String type;
		private DrawingArea area;
		
		public SymbolChange(String s, DrawingArea area){
			type = s;
			this.area = area;
		}
		
		@Override
		public void actionPerformed(ActionEvent arg0) {
			area.setSymbol(Symbol.createSymbol(type));
		}
	}
	
	public static void main(String a[]){
	
		new FlowChart();
	}
}